package com.cc.entity;

import java.util.List;

public class Page<T> {
    /**
     * 当前页码
     */
    private int pageNum = 1;
    /**
     * 每页显示条数
     */
    private int pageSize = 3;
    /**
     * 总记录数
     */
    private int total;
    /**
     * 总页数
     */
    private int totalPage;
    /**
     * 当前页数据
     */
    private List<T> data;

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        if(total > 0) {
            this.total = total;
            this.totalPage = (total % pageSize == 0) ? total / pageSize : total / pageSize + 1;
        }
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Page{" +
                "pageNum=" + pageNum +
                ", pageSize=" + pageSize +
                ", total=" + total +
                ", totalPage=" + totalPage +
                ", data=" + data +
                '}';
    }
}

